import "./index.less";
import { useNavigate } from "react-router-dom";
import { NavBar, Tabs, SearchBar, Badge } from "antd-mobile";
import { communityIntroduction } from "../servece";
import { useEffect, useState } from "react";
const CommunityProfile: React.FC = () => {
  const [communityProfile, setCommunityProfile] = useState<any>({})
  const [address, setAddress] = useState("")//地址
  const [imformation_List,setImformation_List]=useState([])
  const [award_Data_List,setAward_Data_List]=useState([])
  useEffect(() => {
    communityIntroduction({ villageCode: "511602006004" })
      .then((res) => {
        if (res.code == 200) {
          let data = res?.data?.[0]
          setAddress((data?.district || "") + (data?.town || "") + (data?.village || ""))
          setCommunityProfile(data)
          setImformation_List([
            {
              iconUrl: "/images/mycommunity/address.png",
              title: "地址",
              content:data?.address||"",
            },
            {
              iconUrl: "/images/mycommunity/phone.png",
              title: "电话",
              content:data?.phone||"",
            },
            {
              iconUrl: "/images/mycommunity/time.png",
              title: "工作时间",
              content:data?.workTime||"",
            },
          ])
          setAward_Data_List(JSON.parse(data?.honor))
        } else {
          console.log(res.data);
        }
      })
      .catch((error) => {
        console.log(error);
      });
  }, [])


  return (
    <div className="communityProfile">
      <div className="communityProfile-intro">
        <img src="/images/mycommunity/bioqian.png" alt="" className="bioqian" />
        <div className="biaoti"
          style={{ backgroundImage: `url("/images/mycommunity/biaoti.png")` }}>
          <div className="biaoti-title">
            {address}
          </div>
        </div>
        <div className="communityProfile-intro-content">
          {communityProfile?.detail}
        </div>
      </div>
      {award_Data_List.length>0?<div className="communityProfile-Awards">
        {award_Data_List?.map((item, index) => {
          return <div className="communityProfile-Awards-item" key={index}>
            <div className="item_icon"></div>
            <div className="item_title">{item?.key1||111}</div>
          </div>
        })}
      </div>:null}
      <div className="communityProfile-imformation">
        {imformation_List?.map((item, index) => {
          return <div className="imformation_item" key={index}>
            <div className="imformation_title">
              <img className="imformation_title_icon"
                src={item?.iconUrl}
              />
              <div className="imformation_title_title">{item?.title}</div>
            </div>
            <div className="imformation_content">
              {item?.content}
            </div>
          </div>
        })}
      </div>
    </div>
  );
};

export default CommunityProfile;
